﻿@{
    ViewBag.Title = "FileNames";
}

<h2>File Names Template</h2>

<p>&nbsp;</p>

<p>KoTemplates.tt is a template file that allow you to simplify using partial file names.</p>

<h3>Step #1</h3>

<p>Copy the KoTemplates.tt file to a folder where your partial views are located.</p>

<h3>Step #2</h3>

<p>Then right-click on the file and select "Run Custom Tool" item. Remember that you need to re-run the tool every time you add, rename or delete a file,
to maintain the constants in up-to-date state.</p>

<p>The template will generate constanst for your partial names.
It will allow you to use the constants in your cshtml files when you need to specify name of a partial file.</p>
<p>You don't need to worry about typing the file names and directories.</p>

<p>For example, if you have file structure like this:</p>

<p>Views<br />
&nbsp;&nbsp;&nbsp;Examples<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SamplePartials<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Partial1.cshtml<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Partial2.cshtml<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DemoPartials<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;First.cshtml<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Second.cshtml<br />
</p>

<p>3. You will have constants like:</p>

<div class="code">
public static class SamplePartials<br />
{<br />
&nbsp;&nbsp;&nbsp;public const string PARTIAL1 = "SamplePartials/Partial1";<br />
&nbsp;&nbsp;&nbsp;public const string PARTIAL2 = "SamplePartials/Partial2";<br />
}<br />
<br />
public static class DemoPartials<br />
{<br />
&nbsp;&nbsp;&nbsp;public const string FIRST = "DemoPartials/First";<br />
&nbsp;&nbsp;&nbsp;public const string SECOND = "DemoPartials/Second";<br />
}<br />
</div>

<h3>Step #2</h3>

<p>In your cshtml files you can use it as in the example:</p>

<div class="code">&#64;Html.Partial(SamplePartials.PARTIAL1)</div>

<p>&nbsp;</p>
<p>Next &gt; @Html.ActionLink("Code Generation", "CodeGeneration", "Examples")</p>
